import 'package:flutter/material.dart';

class FormUntil {
 static Widget textfiled(
    String formKey,
    String value,
    {
      TextInputType keyboardType = TextInputType.text,
      controller : TextEditingController, 
      onChanged: Function,
      height = 50.0,
      FocusNode? focusNode, 
      InputDecoration? decoration,
      bool obscureText = false,
      IconData? prefixIcon,
      onClear: Function,
      String? hintText,
      margin = 10.0,
    }
  ){
    return Container(
      margin: EdgeInsets.all(margin),
      height: height,
      child: Column(
        children: [
          TextField(
            controller: controller,
            obscureText: obscureText,
            focusNode: focusNode,
            decoration: InputDecoration(
              hintText: hintText,
              icon:Icon(
                prefixIcon,
                size: 20,
              ),
              border: InputBorder.none,
              suffixIcon: GestureDetector(
                child: Offstage(
                  child: Icon(Icons.clear),
                  offstage: value == '',
                ),
                onTap: (){
                  onClear(formKey);
                },
              ),
            ),
            onChanged: (value){
              // print('formuntil $formKey value $value');
              onChanged(formKey, value);
            },
          ),
          Divider(
            height: 1.0,
            color: Colors.grey[400],
          )
        ],
      ),
    );
  }
}